package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**\字符流 OutputStreamWriter写简易记事本
 *
 */
public class Test2 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("note.txt" );
        OutputStreamWriter osw=new OutputStreamWriter(fos,StandardCharsets.UTF_8);
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入内容,单独输入exit退出:");
        while (true){
            String input=scan.nextLine();//用户输入
            if ("exit".equalsIgnoreCase(input)){ //忽略大小写比较字符串
                break;
            }
            osw.write(input);
        }
        osw.close();
    }
}
